﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WPFExcelReport.Controls">

    <Style x:Key="TimelineControlScrollViewerStyle"
       TargetType="ScrollViewer">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ScrollViewer">
                    <Grid Background="{TemplateBinding Background}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <DockPanel Margin="{TemplateBinding Padding}">
                            <local:FrictionScrollViewer DockPanel.Dock="Top"
                                          HorizontalScrollBarVisibility="Hidden"
                                          VerticalScrollBarVisibility="Hidden"
                                          Focusable="false">

                                <local:TimelineRulerControl
                                    Height="20"
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                            </local:FrictionScrollViewer>

                            <ScrollContentPresenter Name="PART_ScrollContentPresenter"
                                                      KeyboardNavigation.DirectionalNavigation="Local"
                                                      CanContentScroll="True" CanHorizontallyScroll="False" 
                                                      CanVerticallyScroll="False"/>
                        </DockPanel>

                        <ScrollBar Name="PART_HorizontalScrollBar"
                                    Orientation="Horizontal"
                                    Grid.Row="1"
                                    Maximum="{TemplateBinding ScrollableWidth}"
                                    ViewportSize="{TemplateBinding ViewportWidth}"
                                    Value="{TemplateBinding HorizontalOffset}"
                                    Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/>

                        <ScrollBar Name="PART_VerticalScrollBar"
                                    Grid.Column="1"
                                    Maximum="{TemplateBinding ScrollableHeight}"
                                    ViewportSize="{TemplateBinding ViewportHeight}"
                                    Value="{TemplateBinding VerticalOffset}"
                                    Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:TimelineControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:TimelineControl}">
                    <Border
                        BorderBrush="{TemplateBinding BorderBrush}" 
                        BorderThickness="{TemplateBinding BorderThickness}">

                        <Grid>
                            <!-- This content is display when no bounds exists
                                 for the timeline control.
                            -->
                            <ContentPresenter
                                x:Name="NoBoundsText"
                                ContentSource="NoBounds"
                                Visibility="Collapsed"/>
                        
                            <local:FrictionScrollViewer
                                x:Name="PART_ScrollViewer"
                                Style="{StaticResource TimelineControlScrollViewerStyle}"
                                VerticalScrollBarVisibility="Auto"
                                HorizontalScrollBarVisibility="Auto">

                            <Grid>
                            
                                <local:TimelineItemsPresenter
                                  x:Name="PART_ItemsPresenter"
                                  ItemsSource="{TemplateBinding Items}"
                                  ItemsPanel="{TemplateBinding ItemsPanel}"
                                  ItemContainerStyleSelector="{TemplateBinding ItemContainerStyleSelector}"
                                />

                                <local:ConnectionsPresenter
                                    x:Name="PART_ConnectionsPresenter"
                                    ItemsSource="{TemplateBinding Connections}"
                                    ItemContainerStyleSelector="{TemplateBinding ConnectionStyleSelector}"
                                />

                            </Grid>

                        </local:FrictionScrollViewer>
                            </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsNoBounds" Value="True">
                            <Setter TargetName="NoBoundsText" Property="Visibility" Value="Visible" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>